package com.ruoyi.driver.user.service.impl;

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.driver.user.service.DriverUserService;
import com.ruoyi.management.basics.ro.GetAssessmentParam;
import com.ruoyi.management.basics.service.ITEmployeeService;
import com.ruoyi.supervise.collectemployee.ro.GetCollectEmployeeParam;
import com.ruoyi.supervise.collectemployee.service.CollectEmployeeService;
import com.ruoyi.supervise.collectemployee.vo.GetCollectEmployeeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class DriverUserServiceImpl implements DriverUserService {

    @Autowired
    private CollectEmployeeService collectEmployeeService;
    @Autowired
    private ITEmployeeService employeeService;


    @Override
    @Transactional(rollbackFor = Exception.class)
    public GetCollectEmployeeVo getCollectemployee(GetAssessmentParam param, String userName) {
        if(StringUtils.isEmpty(userName)){
            throw new ServiceException("获取当前驾驶员信息失败");
        }
        String idCard = employeeService.getIdCardByUsername(userName);
        if(StringUtils.isEmpty(idCard)){
            throw new ServiceException("获取当前驾驶员信息失败");
        }
        GetCollectEmployeeParam employeeParam = new GetCollectEmployeeParam();
        employeeParam.setIdcard(idCard);
        employeeParam.setYear(param.getYear());
        return collectEmployeeService.getCollectemployee(employeeParam);
    }
}
